<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta charset="UTF-8">
	<title>CRM后台审核管理</title>
	<link rel="stylesheet" href="../css/bootstrap-datetimepicker.min.css">
	<link rel="stylesheet" href="../css/fileinput.min.css">
	<link rel="stylesheet" href="../css/bootstrap-editable.css">
	<link rel="stylesheet" href="../css/bootstrap.min.css">
	<script src="../js/jquery-1.11.1.js"></script>
	<script src="../js/bootstrap.min.js"></script>
	<script src="../js/bootstrap-datetimepicker.min.js"></script>
	<script src="../js/bootstrap-datetimepicker.zh-CN.js"></script>
	<script src="http://cdn.bootcss.com/jquery-validate/1.14.0/jquery.validate.min.js"></script>
	<script src="http://cdn.bootcss.com/jquery-validate/1.14.0/additional-methods.min.js"></script>
	<script src="../js/messages_zh.js"></script>
	<script src="../js/fileinput.min.js"></script>
	<script src="../js/fileinput_locale_zh.js"></script>
	<script src="../js/bootstrap-editable.min.js"></script>
	<style>
		
	</style>
	<script>
		$(function(){
			$('#login').css('display','block');
			$('#logon').css('display','none');
			// $("[data-toggle='tooltip']").tooltip();
			var b = $('<div>',{'id':'true-message','style':'text-align:center;color:green'});
			
				
/*		登录			*/

			$('#loginForm').validate({
				rules:{
					adminLoginName:{
						required:true,
						remote:'../public/check.php'
					},
					loginPassword:{
						required:true,
					},
				},
				messages:{
					adminLoginName:{
						required:'请填写用户名',
						remote:'用户名不存在'
					},
					loginPassword:{
						required:'请填写密码'
					},
				},
				showErrors:function(){
					for( var i=0,e,el; e=this.errorList[i++]; ) {
						el = $(e.element);
						el.parents('.form-group').removeClass('has-success').addClass('has-error');
						if(el.data('bs.popover')) {
							el.data('bs.popover').options.content=e.message;
							el.data('bs.popover').options.container='body';
						} else {
							el.popover({placement:'right',trigger:'manual',container:'body',content:e.message});
						}
						el.popover('show');
					}
					for( var i=0,s,el; s=this.successList[i++]; ) {
						el = $(s);
						el.parents('.form-group').addClass('has-success').removeClass('has-error');
						el.popover('hide');
					}
				},
			})
			var person;
			var pid;
			$('#loginButton').click(function(){
				var c = $('form').valid();
				if( c ){
					$.ajax({
						url:'bg_login.php',
						data:{
							name:$('input[name=adminLoginName]').val(),
							psw:$('input[name=loginPassword]').val()
						},
						type:'post',
						dataType:'JSON',
						success:function(data){
							var f = $('#login-panel-body #false-message');
							var t = $('#login-panel-body #true-message');
							if(data.success){
								if(t.length<1){
									$('<div>',{html:data.msg,'id':'true-message','style':'text-align:center;color:green'}).appendTo($('#login-panel-body'))
								}
								setTimeout(function(){
									window.location.href='bg_home.html';
								},1000);
							}else{
								if(f.length<1){
									$('<div>',{html:data.msg,'id':'false-message','style':'text-align:center;color:red'}).appendTo($('#login-panel-body'))
								}else{
									$('#false-message').html(data.msg);
								}
							}
						}
					})
				}
			})
			$('#goLogon').click(function(){
				$('#login').css('display','none');
				$('#logon').css('display','block');
			})
			
/*		注册			*/	
			
			$('#logonForm').validate({
				rules:{
					adminLogonName:{
						required:true,
						remote:'check.php'
					},
					logonPassword:{
						required:true,
					},
					rePassword:{
						equalTo:'input[name=logonPassword]',
						required:true
					}
				},
				messages:{
					logonName:{
						required:'请填写用户名',
						remote:'用户名已存在'
					},
					logonPassword:{
						required:'请填写密码'
					},
					rePassword:{
						equalTo:'密码不一样',
						required:'请填写密码'
					}
				},
				showErrors:function(){
					for( var i=0,e,el; e=this.errorList[i++]; ) {
						el = $(e.element);
						el.parents('.form-group').removeClass('has-success').addClass('has-error');
						if(el.data('bs.popover')) {
							el.data('bs.popover').options.content=e.message;
						} else {
							el.popover({placement:'top',trigger:'manual',container:'body',content:e.message});
						}
						el.popover('show');
					}
					for( var i=0,s,el; s=this.successList[i++]; ) {
						el = $(s);
						el.parents('.form-group').addClass('has-success').removeClass('has-error');
						el.popover('hide');
					}
				},

			})
			$('#logonButton').click(function(){
				var c = $('form').valid();
				if( c ){
					$.ajax({
						url:'bg_logon.php',
						data:{
							name:$('input[name=adminLogonName]').val(),
							psw:$('input[name=logonPassword]').val()
						},
						type:'post',
						dataType:'JSON',
						success:function(data){
							var f = $('#logon-panel-body #false-message');
							var t = $('#logon-panel-body #true-message');
							if(data.success){
								if(t.length<1){
									remove($('#logon-panel-body #false-message'));
									$('<div>',{html:data.msg,'id':'true-message','style':'text-align:center;color:green'}).appendTo($('#logon-panel-body'))
								}
								setTimeout(function(){
									$("body").load("home.html");
								},1000);
							}else{
								if(f.length<1){
									remove($('#logon-panel-body #true-message'));
									$('<div>',{html:data.msg,'id':'false-message','style':'text-align:center;color:red'}).appendTo($('#logon-panel-body'))
								}else{
									remove($('#logon-panel-body #true-message'));
									$('#false-message').html(data.msg);
								}
							}
						}
					})
				}
			})
			$('#goLogin').click(function(){
				$('#login').css('display','block');
				$('#logon').css('display','none');
			})
			$('#loginVerifyCodeChange').click(function(){
				$('#loginVerifyCode').attr({'src':'../public/verifyCode.php?a='+new Date().getTime()});
			})
			$('#logonVerifyCodeChange').click(function(){
				$('#logonVerifyCode').attr({'src':'../public/verifyCode.php?a='+new Date().getTime()});
			})
		})
			
		</script>
</head>

<body>
	
<!--    Log-in		-->

	<div id="login">
		<div class="container">
			<div class="row">
				<div class="panel panel-primary" style="width: 400px;margin:auto;">
	            	<div class="panel-heading">
	                	<div class="panel-title">
							用户登录
	                    </div>
	                </div>
					<form id="loginForm" class="form-horizontal" >
					<div id="login-panel-body" class="panel-body">
                		<div class="form-group">
	                		<div class="col-xs-4 text-right" style="margin-top: 7px">
	                    			用户名：
	                		</div>
	                    	<div class="col-xs-8">
									<input class="form-control" type="text" name="adminLoginName" />
							</div>
						</div>
						<div class="form-group">
							<div class="col-xs-4 text-right" style="margin-top: 7px">
	                			密&nbsp;&nbsp;&nbsp;&nbsp;码：
	                		</div>
	                    	<div class="col-xs-8">
									<input class="form-control" type="text" name="loginPassword" />
							</div>
						</div>
						<div class="form-group">
							<div class="col-xs-4 text-right" style="margin-top: 7px">
								验证码:
							</div>
							<div class="col-xs-8">
								<input  class="form-control" type="text" name=loginCAPTCHA />
							</div>
						</div>
						<div class="form-group">
							<div class="col-xs-offset-4" style="padding-left:15px" id="CAPTCHA">
								<span class="tp_txt">请输入图中字符，不区分大小写</span>
								<label id="loginVerifyCodeChange">
									<img class="verifyCode" src="../public/verifyCode.php" id="loginVerifyCode" />
									<a href="#">看不清</a>
								</label>
							</div>
						</div>
					</div>
					</form>	
					<div class="panel-footer" style="text-align:right" >
						<button id="loginButton" class="btn btn-info" type="submit">登录</button>
						<button id="goLogon" class="btn btn-default">注册</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	
<!--    Log-on		-->

	<div id="logon">
		<div class="container">
			<div class="row">
				<div class="panel panel-primary" style="width: 400px;margin:auto;">
	            	<div class="panel-heading">
	                	<div class="panel-title">
							用户登录
	                    </div>
	                </div>
					<form id="logonForm" class="form-horizontal" >
					<div id="logon-panel-body" class="panel-body">
                		<div class="form-group">
	                		<div class="col-xs-4 text-right" style="margin-top: 7px">
	                    			用&nbsp;&nbsp;户&nbsp;&nbsp;名：
	                		</div>
	                    	<div class="col-xs-8">
								<input class="form-control" type="text" name="adminLogonName" />
							</div>
						</div>
						<div class="form-group">
							<div class="col-xs-4 text-right" style="margin-top: 7px">
	                			&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;&nbsp;码：&nbsp;&nbsp;
	                		</div>
	                    	<div class="col-xs-8">
								<input class="form-control" type="text" name="logonPassword" />
							</div>
						</div>
						<div class="form-group">
							<div class="col-xs-4 text-right" style="margin-top: 7px">
	                			确认密码：
	                		</div>
	                    	<div class="col-xs-8">
								<input class="form-control" type="text" name="rePassword" />
							</div>
						</div>
						<div class="form-group">
							<div class="col-xs-offset-4" style="padding-left:15px" id="CAPTCHA">
								<span class="tp_txt">请输入图中字符，不区分大小写</span>
								<label id="logonVerifyCodeChange">
									<img class="verifyCode" src="../public/verifyCode.php" id="logonVerifyCode" />
									<a href="#">看不清</a>
								</label>
							</div>
						</div>
					</div>
					</form>	
					<div class="panel-footer" style="text-align:right" >
						<button id="logonButton" class="btn btn-info" type="submit">&nbsp;&nbsp;注&nbsp;&nbsp;&nbsp;&nbsp;册&nbsp;&nbsp;</button>
						<a id="goLogin" class="btn btn-default">返回登录</a>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
